#!/bin/bash  
  
root=`git rev-parse --show-toplevel`

format=$root/tools/format

diffs=`git diff-index --cached --diff-filter=ACMRT --name-only HEAD`
while read -r file; do
    fullpath="$root/$file"
    if ! sh "$format/code.sh" --path "$fullpath"; then
        exit 1
    fi
    git add "$fullpath"
done <<< "$diffs"
